using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ProjectorEffect : MonoBehaviour, IReuseable
{
    Projector projector;

    public bool CanReuse()
    {
        return !gameObject.activeSelf;
    }

    public void OnReuse(Vector3 position, Vector3 forward)
    {

    }

    private Transform follower;
    private Vector3 localPos;

    public void SetFollower(SelectableObject selectableObject) 
    {
        this.follower = selectableObject.transform;
        this.localPos = selectableObject.projectorLocalPos;
        if (projector == null) { projector = GetComponent<Projector>(); }

        transform.localEulerAngles = new Vector3(90, 0, 0);  
        transform.position = follower.position + localPos;
        projector.orthographicSize = selectableObject.projectorRadius;
        projector.material.color = selectableObject.projectorColor;

        gameObject.SetActive(true);
    }

    private void Update()
    {
        transform.position = follower.position + localPos;
    }
}
